<?php
class UploadControl extends BaseControl
{
    protected $cssFile = 'upload/uploadify';
    protected $jsFile = 'upload/uploadify, upload/swfobject';
    protected $urlPost;
    protected $data = array();
    protected $auto = true;
    protected $multi = false;

    public function UploadControl($url_post = null)
    {
        parent::__construct();
        $this->urlPost = $url_post;
    }

    public function Render()
    {
        $data = null;
        foreach ($this->data as $key => $value)
        {
            $data .= ", '$key':'$value'";
        }

        $this->Replace('name', $this->name);
        $this->Replace('url_upload_img', BaseConfig::GetInstance()->URL_IMG.FS.'upload');
        $this->Replace('buttonImg', $this->GetButtonImg());
        $this->Replace('session_id', Session::GetId());
        $this->Replace('url_post', $this->urlPost);
        $this->Replace('data', $data);
        $this->Replace('auto', $this->auto ? 'true':'false');
        $this->Replace('multi', $this->multi ? 'true':'false');
        return parent::Render();
    }

    protected function GetButtonImg()
    {
        return null;
    }

    public function AddParam($key, $value)
    {
        $this->data[$key] = $value;
    }

    public function SetAuto($auto)
    {
        $this->auto = $auto;
    }

    public function SetMulti($multi)
    {
        $this->multi = $multi;
    }
}
?>
